<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');

class Admin_layout
{

    var $obj;
    var $layout;
    function Admin_layout($layout = "") {
        $this->obj =& get_instance();
        $this->layout = $layout;        
        $this->obj->load->Model("Mconfig");
        $this->obj->load->helper(array('form', 'url'));
        $this->obj->load->library('form_validation');
        $this->obj->load->library('pagination');
        $this->obj->load->helper("url");

        // check login
        $sess =$this->obj->session->userdata('users_Id_Admin');
        //var_dump($sess);
        if($sess == null) {
            redirect('admin/login');
        }        
    }

    function setLayout($layout)
    {
      $this->layout = $layout;
    }

    function view($view, $data=null, $return=false)
    {

        $loadedData = array();
        $loadedData['content_for_Main'] = $this->obj->load->view($view,$data,true);
        $loadedData['content_for_Name_Admin_Login'] =  $this->obj->session->userdata('users_FullName');

        if($return) {
            $output = $this->obj->load->view($this->layout, $loadedData, true);
            return $output;
        }
        else {
            $this->obj->load->view($this->layout, $loadedData, false);
        }
    }
    
}